/**
 * Created by mac on 2017/12/22.
 */
import {GET_USER_INFO_FAIL, GET_USER_INFO_SUCCESS, GET_USER_INFO} from '../actions/userInfo'

export default function (state = {
    isLoading: false,
    userInfo: {},
    errorMsg: ''
}, action) {
    switch (action.type) {
        case GET_USER_INFO:
            return {
                ...state,
                isLoading: true,
                userInfo: {},
                errorMsg: ''
            }
        case GET_USER_INFO_SUCCESS:
            return {
                ...state,
                isLoading: false,
                userInfo: action.userInfo,
                errorMsg: ''
            }
        case GET_USER_INFO_FAIL:
            return {
                ...state,
                isLoading: false,
                userInfo: {},
                errorMsg: '请求错误'
            }
        default:
            return state
    }
}